package com.arcgis.demo;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.arcgis.utils.SystemPageWriter;

public class DataProvider extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public DataProvider() {
		
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String k = request.getParameter("k");
		if(k==null || k.equals("")) return;
		JSONObject obj = new JSONObject();
		obj.put("showmap", true);
		obj.put("wkid", 4326);
		
	/*	switch (k) {
		case "polygon":
			
			List<List<Double[]>> rings = new ArrayList<List<Double[]>>();
			
			List<Double[]> ring = new ArrayList<Double[]>();
			ring.add(new Double[]{102.046 , 31.802});//x,y
			ring.add(new Double[]{104.136 , 31.736});
			ring.add(new Double[]{100.443 , 30.466});
			ring.add(new Double[]{102.046 , 31.802});
			rings.add(ring);
			
			List<Double[]> ring2 = new ArrayList<Double[]>();
			ring2.add(new Double[]{111.523 ,34.345});//x,y
			ring2.add(new Double[]{114.274 ,34.450});
			ring2.add(new Double[]{113.930 ,33.260});
			ring2.add(new Double[]{112.052 ,32.916});
			ring2.add(new Double[]{111.523 ,34.345});
			rings.add(ring2);
			
			obj.put("rings", rings);
			break;

		case "polyline":
			List<Double[]> pointsxy = new ArrayList<Double[]>();
			pointsxy.add(new Double[]{102.046 , 31.802});
			pointsxy.add(new Double[]{104.136 , 31.736});
			pointsxy.add(new Double[]{100.443 , 30.466});
			obj.put("paths", pointsxy);
			break;
			
		default:
			break;
		}*/
		SystemPageWriter.writeToPage(response, obj);
	}

}
